<?php

namespace Drupal\shushengyuan\Schemas;

/**
 * @OA\Schema(
 *   schema="SearchAutocomplete",
 *   type="object",
 *   description="SearchAutocomplete"
 * )
 */
class SearchAutocomplete extends AbstractBaseModel {

  protected function getEntityType() {
    return FALSE;
  }

  protected function setValue() {
    [$item] = $this->context;
    /**
     * keys: "abcd"
     * prefix: null
     * results: "1"
     * suggestion_prefix: ""
     * suggestion_suffix: "cd"
     * url: null
     * user_input: "ab"
     */
    $value = [
      /**
       * @OA\Property(
       *   property="input",
       *   type="string",
       *   description="输入的词",
       * ),
       */
      'input' => (string) $item['user_input'],
      /**
       * @OA\Property(
       *   property="prefix",
       *   type="string",
       *   description="联想前缀",
       * ),
       */
      'prefix' => (string) $item['suggestion_prefix'],
      /**
       * @OA\Property(
       *   property="suffix",
       *   type="string",
       *   description="联想后缀",
       * ),
       */
      'suffix' => (string) $item['suggestion_suffix'],
      /**
       * @OA\Property(
       *   property="results",
       *   type="integer",
       *   description="结果总数",
       * ),
       */
      'results' => (int) $item['results'],
      /**
       * @OA\Property(
       *   property="keys",
       *   type="string",
       *   description="完整词",
       * ),
       */
      'keys' => (string) $item['keys'],
    ];
    $this->merge($value);
  }
}
